package com.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public FanoutExchange exchange()
    {
        //创建交换机
        return  new FanoutExchange("sunjob_exchange");
    }

    @Bean
    public Queue   queue(){
        //创建队列
        return new Queue("sunjob_queue");
    }

    @Bean
    public Binding binding(){
        //交换机绑定队列
        return BindingBuilder.bind(queue()).to(exchange());
    }


}
